package com.youdianda.mapper;

import com.youdianda.entity.SysFgxMenu;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysMenuFgxMapper {

    @Select("select * from youdianda.sys_menu where pid=0 and del_flag=0")
    List<SysFgxMenu> menuList();

    @Select("select * from youdianda.sys_menu where pid=#{pid} and del_flag=0")
    List<SysFgxMenu> childrenByPid(long pid);

    @Select("select * from youdianda.sys_menu where id=#{id} and del_flag=0")
    SysFgxMenu rowInfoById(Integer id);

    void update(SysFgxMenu sysMenu);

    @Insert("insert into youdianda.sys_menu " +
            "(pid, path, component, title, icon, is_show, is_cache, is_link, redirect, create_date, update_date, del_flag, type, sort, mark, default_data) " +
            "VALUES (#{pid},#{path},#{component},#{title},#{icon},#{is_show},#{is_cache},#{is_link},#{redirect},#{createDate},#{updateDate},#{delFlag},#{type},#{sort},#{mark},#{defaultData})")
    void add(SysFgxMenu sysMenu);

    @Delete("delete from youdianda.sys_menu where id=#{id}")
    void del(Integer id);
}
